/**
 * Copyright 2010  Pavel Nemec <nemecp4@gmail.com> <br>
 * <br>
 * License - GPLv3<br>
 *<br>
 * This program is free software; you can redistribute it and/or modify<br>
 * it under the terms of the GNU General Public License as published by<br>
 * the Free Software Foundation; either version 3 of the License, or<br>
 * (at your option) any later version.<br>
 *<br>
 * This program is distributed in the hope that it will be useful,<br>
 * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
 * GNU General Public License for more details.<br>
 *<br>
 * You should have received a copy of the GNU General Public License<br>
 * along with this program. If not, see <http://www.gnu.org/licenses/>.<br>
 *<br>
 */
package eu.whowie.jast.client.nat;

import java.util.Hashtable;

/**
 * @author Pavel Nemec
 * 
 */
public class ObjectMapper<T> {

	private Hashtable<Integer, T> objectMap = new Hashtable<Integer, T>();

	public int storeObject(T object) {
		int id = getNewId();
		objectMap.put(id, object);
		return id;
	}

	private int getNewId() {
		return (int) (10000000 * Math.random());
	}

	/**
	 * @param parrent
	 */
	public T get(int parrent) {
		if (objectMap.containsKey(parrent))
			return objectMap.get(parrent);
		else {
			throw new RuntimeException(
					"you are trying access object with uknown ID: " + parrent);
		}

	}
}
